<script setup lang="ts">
import { ref, reactive } from "vue";
import { Check } from "@element-plus/icons-vue"
const stepsActive = ref(0)
const info = reactive({
    phoneNumber: '',
    slider: 0,
    vCode: ''
})

const password = reactive({
    input: '',
    confirm: ''
})

const handleNext = (step: number): void => {
    stepsActive.value = step
}

</script>

<template>
    <div class="full-layout password">
        <div class="nav">账号安全</div>
        <div class="steps-box">
            <div class="steps">
                <el-steps :active="stepsActive" align-center finish-status="success">
                    <el-step>
                        <template #title>
                            <span class="title">填写验证信息</span>
                        </template>
                    </el-step>
                    <el-step>
                        <template #title>
                            <span class="title">设置新密码</span>
                        </template>
                    </el-step>
                    <el-step>
                        <template #title>
                            <span class="title">设置完成</span>
                        </template>
                    </el-step>
                </el-steps>
            </div>
        </div>
        <div class="box">
            <div v-if="stepsActive === 0" class="item">
                <div class="row">
                    <el-input v-model="info.phoneNumber" placeholder="手机号"></el-input>
                </div>
                <div class="validate-slider row">
                    <div class="title">
                        <span>请按住滑块，拖到最右边</span>
                    </div>
                    <el-slider v-model="info.slider" :show-tooltip="false"></el-slider>
                </div>
                <div class="row">
                    <el-input v-model="info.vCode" placeholder="手机验证码"></el-input>
                    <el-button
                        type="primary"
                        :disabled="info.slider < 100"
                        class="validate-button"
                    >获取验证码</el-button>
                </div>
                <div class="row">
                    <el-button type="primary" class="button" @click="handleNext(1)">下一步</el-button>
                </div>
            </div>
            <div v-if="stepsActive === 1" class="item">
                <div class="row">
                    <el-input v-model="password.input" placeholder="设置密码"></el-input>
                </div>
                <div class="row">
                    <el-input v-model="password.confirm" placeholder="确认密码"></el-input>
                </div>
                <div class="row">
                    <el-button type="primary" class="button" @click="handleNext(2)">下一步</el-button>
                </div>
            </div>
            <div v-if="stepsActive === 2" class="item">
                <div class="row top">
                    <div class="icon-box">
                        <Check class="icon" />
                    </div>
                    <div class="text">设置成功</div>
                </div>
                <div class="row">
                    <div class="tips">您已经成功设置密码，请使用新密码登录</div>
                </div>
                <div class="row">
                    <el-button type="primary" class="button">马上登录</el-button>
                </div>
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>
.password {
    .steps-box {
        max-width: 1200px;
        margin: 24px auto 0px;
    }
    .steps {
        margin-left: -82px;
        .title {
            padding: 0px 6px;
            font-size: 12px;
        }
        :deep(.el-step__main) {
            margin-left: 10px;
            position: absolute;
            top: 0px;
            line-height: 24px;
            left: 50%;
            background: #fff;
        }
        :deep(.el-step__title) {
            line-height: inherit;
        }
        :deep(.is-success) {
            --el-color-success: #1890ff;
            .el-step__line {
                background-color: #1890ff;
            }
        }
        :deep(.is-process) {
            &.el-step__title {
                color: rgba(0, 0, 0, 0.85);
            }
            .el-step__icon {
                background: #1890ff;
                color: #fff;
                border-color: #1890ff;
            }
            // .el-step__line {
            //     background-color: #1890ff;
            // }
        }
    }
    .box {
        width: 300px;
        margin: 18px auto 0px;
        :deep(.el-input__inner) {
            height: 34px;
            line-height: 34px;
        }
        :deep(.el-button) {
            height: 34px;
            line-height: 34px;
            border-radius: 0px;
        }
        .item {
            display: flex;
            flex-direction: column;
            .row {
                margin-bottom: 16px;
                display: flex;
                align-items: center;
                justify-content: center;
                .icon-box {
                    height: 28px;
                    width: 28px;
                    box-sizing: border-box;
                    border: 2px solid #6bc839;
                    border-radius: 14px;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    .icon {
                        height: 20px;
                        width: 20px;
                        color: #6bc839;
                    }
                }
                .text {
                    font-size: 18px;
                    color: #333333;
                    padding-left: 8px;
                    font-weight: 600;
                }
                .tips {
                    font-size: 12px;
                    color: #333333;
                    line-height: 34px;
                }
            }
            .top {
                margin-top: 16px;
            }
        }
        .validate-slider {
            position: relative;
            background: #1890ff;
            .title {
                position: absolute;
                top: 0px;
                left: 0px;
                display: flex;
                justify-content: center;
                align-items: center;
                height: 100%;
                width: 100%;
                font-size: 12px;
                color: #555555;
                z-index: 1;
            }
            :deep(.el-slider) {
                height: 28px;
                --el-slider-height: 100%;
                --el-slider-border-radius: 0px;
                --el-slider-runway-bg-color: #f8f8f8;
                --el-slider-main-bg-color: #1890ff;
                width: calc(100% - 40px);
                margin-left: 40px;
            }
            :deep(.el-slider__button-wrapper) {
                width: 40px;
                height: 28px;
                background-color: #ffffff;
                border: 1px solid #c2c2c2;
                top: 0px;
                box-sizing: border-box;
                transform: translateX(-40px);
                &::after {
                    content: ">>";
                    color: #555555;
                    font-size: 14px;
                    line-height: 26px;
                    letter-spacing: -3px;
                }
            }
            :deep(.el-slider__button) {
                display: none;
            }
        }

        .validate-button {
            margin-left: 12px;
        }

        .button {
            margin-top: 8px;
            width: 100%;
        }
    }
}
</style>
